#include"process.h"
#include<stdio.h>
#include<unistd.h>
#include<string.h>

#define SIZE 101
#define STYLE '#'



void Flushprocess(const char* bs,double total,double current)
{
  char buffer[SIZE]={0};
  const char* lable = "/|-\\";
  static int k = 0; 
  double rate = current * 100 / total;
  int num = (int)rate;
  int i = 0;
  for(;i < num;i++)
  {
    buffer[i] = STYLE;
  }
  printf("%s...[%-100s][%.1lf%%][%c]\r",bs,buffer,rate,lable[k % strlen(lable)]);
  k++;

  fflush(stdout);
  if(rate >= 100)
    printf("\n");

}







void process()
{
  int raet = 0;
  char buffer[SIZE]={0};
  const char* lable = "/-\\|";
  int size = strlen(lable);
  //memset(buffer,0,sizeof(buffer));
  while(raet <= 100)
  {
    printf("[%-100s][%d%%][%c]\r",buffer,raet,lable[raet%size]);
    fflush(stdout);
    buffer[raet]=STYLE;
    usleep(50000);
    raet++;
  }
  printf("\n");
}
